*------------------------------------------------------------------------------*
*	Paper:			FDI and Political Preferences in Non-Democratic Regimes
*	Authors:		Tobias Rommel
*	Version:		June 28, 2023
*	Data:			Afrobarometer, Pew Global Attitudes, fdimarkets
*	Task:			Replication of Empirical Analysis
*------------------------------------------------------------------------------*


clear all
set more off
capture log close
local dir = "/Users//`=c(username)'/Downloads/Rommel_FDIsupport_CPS_Replication"
cd "`dir'"
log using "Rommel_FDIsupport_CPS_Analysis.log"



***** 1. Afrobarometer Survey Data
*------------------------------------------------------------------------------*

*** Load data
use "Rommel_FDIsupport_CPS_AFB.dta", clear

*** TABLE A-2: Share of respondents exposed to FDI
tab cname, sum(fdi_treat)

*** Model specification
keep if fdi_treat==1
* Controls
global C1 age female unempl urban
global C2 interest news 
global C3 i.race 
* Sample
xtreg problem c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
gen sample=e(sample)==1

*** TABLE A-1: Summary statistics, Afrobarometer
tabstat problem condlive condecon trustelec trustlead trustpart demoqua demosat demosup ///
	educlvl lnfdi_jobs lnfdi_capex age female unempl urban interest news if sample==1, ///
	stats(N mean sd min max) format(%10.2f)

*** Set 1: Economic Grievances
* Self-Reported Economic Problems
xtreg problem c.lnfdi_jobs##c.educlvl $C1 i.round, i(cname)
est store problem1
xtreg problem c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store problem2
xtreg problem c.lnfdi_jobs##c.educlvl $C1 $C2 $C3 i.round, i(cname)
est store problem3
xtreg problem c.lnfdi_capex##c.educlvl $C1 $C2 i.round, i(cname)
est store problem4
xtprobit problem c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store problem5
xtreg problem c.lnfdi_jobs_10##c.educlvl $C1 $C2 i.round, i(cname)
est store problem6
* Currently Bad Living Conditions
xtreg condlive c.lnfdi_jobs##c.educlvl $C1 i.round, i(cname)
est store condlive1
xtreg condlive c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store condlive2
xtreg condlive c.lnfdi_jobs##c.educlvl $C1 $C2 $C3 i.round, i(cname)
est store condlive3
xtreg condlive c.lnfdi_capex##c.educlvl $C1 $C2 i.round, i(cname)
est store condlive4
xtoprobit condlive c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store condlive5
xtreg condlive c.lnfdi_jobs_10##c.educlvl $C1 $C2 i.round, i(cname)
est store condlive6
* Currently Bad Economic Situation
xtreg condecon c.lnfdi_jobs##c.educlvl $C1 i.round, i(cname)
est store condecon1
xtreg condecon c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store condecon2
xtreg condecon c.lnfdi_jobs##c.educlvl $C1 $C2 $C3 i.round, i(cname)
est store condecon3
xtreg condecon c.lnfdi_capex##c.educlvl $C1 $C2 i.round, i(cname)
est store condecon4
xtoprobit condecon c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store condecon5
xtreg condecon c.lnfdi_jobs_10##c.educlvl $C1 $C2 i.round, i(cname)
est store condecon6

*** TABLE A-4: Economic Grievances - Main Models
esttab problem2 problem4 problem5 condlive2 condlive4 condlive5 condecon2 condecon4 condecon5, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(educlvl lnfdi_jobs c.lnfdi_jobs#c.educlvl lnfdi_capex c.lnfdi_capex#c.educlvl age female unempl urban interest news) ///
	drop(*round _cons) eqlabels("" "") nogaps ///
	coeflabel(educlvl "Education level" ///
		lnfdi_jobs "FDI jobs created" ///
		lnfdi_capex "FDI capital expenditure" ///
		c.lnfdi_jobs#c.educlvl "FDI jobs * education" ///
		c.lnfdi_capex#c.educlvl "FDI capex * education" ///
		age "Age in years" female "Female" unempl "Unemployed" ///
		urban "Urban resident" interest "Political interest" ///
		news "Newspaper consumption")

*** TABLE A-5: Economic Grievances - Robustness Tests
esttab problem1 problem3 problem6 condlive1 condlive3 condlive6 condecon1 condecon3 condecon6, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p ll, fmt(0 0 3 2) labels("\# respondents" "\# of countries" "Prob > Chi2" "Log likelihood")) ///
	order(educlvl lnfdi_jobs c.lnfdi_jobs#c.educlvl age female unempl urban interest news *race) ///
	drop(*round _cons) eqlabels("" "") nogaps ///
	coeflabel(educlvl "Education level" ///
		lnfdi_jobs "FDI jobs created" ///
		lnfdi_capex "FDI capital expenditure" ///
		c.lnfdi_jobs#c.educlvl "FDI jobs * education" ///
		c.lnfdi_capex#c.educlvl "FDI capex * education" ///
		age "Age in years" female "Female" unempl "Unemployed" ///
		urban "Urban resident" interest "Political interest" ///
		news "Newspaper consumption" 1.race "Black/African" ///
		2.race "White/European" 3.race "Colored/mixed race" ///
		4.race "Arab/Lebanese/North African" 5.race "Other")

*** Set 2: Distrust in State Institutions
* Distrust in Electoral Commission
xtreg trustelec c.lnfdi_jobs##c.educlvl $C1 i.round, i(cname)
est store trustelec1
xtreg trustelec c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store trustelec2
xtreg trustelec c.lnfdi_jobs##c.educlvl $C1 $C2 $C3 i.round, i(cname)
est store trustelec3
xtreg trustelec c.lnfdi_capex##c.educlvl $C1 $C2 i.round, i(cname)
est store trustelec4
xtprobit trustelec c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store trustelec5
xtreg trustelec c.lnfdi_jobs_10##c.educlvl $C1 $C2 i.round, i(cname)
est store trustelec6
* Distrust in Leader
xtreg trustlead c.lnfdi_jobs##c.educlvl $C1 i.round, i(cname)
est store trustlead1
xtreg trustlead c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store trustlead2
xtreg trustlead c.lnfdi_jobs##c.educlvl $C1 $C2 $C3 i.round, i(cname)
est store trustlead3
xtreg trustlead c.lnfdi_capex##c.educlvl $C1 $C2 i.round, i(cname)
est store trustlead4
xtprobit trustlead c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store trustlead5
xtreg trustlead c.lnfdi_jobs_10##c.educlvl $C1 $C2 i.round, i(cname)
est store trustlead6
* Distrust in Ruling Party
xtreg trustpart c.lnfdi_jobs##c.educlvl $C1 i.round, i(cname)
est store trustpart1
xtreg trustpart c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store trustpart2
xtreg trustpart c.lnfdi_jobs##c.educlvl $C1 $C2 $C3 i.round, i(cname)
est store trustpart3
xtreg trustpart c.lnfdi_capex##c.educlvl $C1 $C2 i.round, i(cname)
est store trustpart4
xtprobit trustpart c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store trustpart5
xtreg trustpart c.lnfdi_jobs_10##c.educlvl $C1 $C2 i.round, i(cname)
est store trustpart6

*** TABLE A-6: Distrust in State Institutions - Main Models
esttab trustelec2 trustelec4 trustelec5 trustlead2 trustlead4 trustlead5 trustpart2 trustpart4 trustpart5, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(educlvl lnfdi_jobs c.lnfdi_jobs#c.educlvl lnfdi_capex c.lnfdi_capex#c.educlvl age female unempl urban interest news) ///
	drop(*round _cons) eqlabels("" "") nogaps ///
	coeflabel(educlvl "Education level" ///
		lnfdi_jobs "FDI jobs created" ///
		lnfdi_capex "FDI capital expenditure" ///
		c.lnfdi_jobs#c.educlvl "FDI jobs * education" ///
		c.lnfdi_capex#c.educlvl "FDI capex * education" ///
		age "Age in years" female "Female" unempl "Unemployed" ///
		urban "Urban resident" interest "Political interest" ///
		news "Newspaper consumption")

*** TABLE A-7: Distrust in State Institutions - Robustness Tests
esttab trustelec1 trustelec3 trustelec6 trustlead1 trustlead3 trustlead6 trustpart1 trustpart3 trustpart6, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p ll, fmt(0 0 3 2) labels("\# respondents" "\# of countries" "Prob > Chi2" "Log likelihood")) ///
	order(educlvl lnfdi_jobs c.lnfdi_jobs#c.educlvl age female unempl urban interest news *race) ///
	drop(*round _cons) eqlabels("" "") nogaps ///
	coeflabel(educlvl "Education level" ///
		lnfdi_jobs "FDI jobs created" ///
		lnfdi_capex "FDI capital expenditure" ///
		c.lnfdi_jobs#c.educlvl "FDI jobs * education" ///
		c.lnfdi_capex#c.educlvl "FDI capex * education" ///
		age "Age in years" female "Female" unempl "Unemployed" ///
		urban "Urban resident" interest "Political interest" ///
		news "Newspaper consumption" 1.race "Black/African" ///
		2.race "White/European" 3.race "Colored/mixed race" ///
		4.race "Arab/Lebanese/North African" 5.race "Other")

*** Set 3: Type of Political Regime
* Opinion: Country Is Not a Democracy
xtreg demoqua c.lnfdi_jobs##c.educlvl $C1 i.round, i(cname)
est store demoqua1
xtreg demoqua c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store demoqua2
xtreg demoqua c.lnfdi_jobs##c.educlvl $C1 $C2 $C3 i.round, i(cname)
est store demoqua3
xtreg demoqua c.lnfdi_capex##c.educlvl $C1 $C2 i.round, i(cname)
est store demoqua4
xtoprobit demoqua c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store demoqua5
xtreg demoqua c.lnfdi_jobs_10##c.educlvl $C1 $C2 i.round, i(cname)
est store demoqua6
* Dissatisfaction with How Democracy Works
xtreg demosat c.lnfdi_jobs##c.educlvl $C1 i.round, i(cname)
est store demosat1
xtreg demosat c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store demosat2
xtreg demosat c.lnfdi_jobs##c.educlvl $C1 $C2 $C3 i.round, i(cname)
est store demosat3
xtreg demosat c.lnfdi_capex##c.educlvl $C1 $C2 i.round, i(cname)
est store demosat4
xtoprobit demosat c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store demosat5
xtreg demosat c.lnfdi_jobs_10##c.educlvl $C1 $C2 i.round, i(cname)
est store demosat6
* Preferences for Democracy
xtreg demosup c.lnfdi_jobs##c.educlvl $C1 i.round, i(cname)
est store demosup1
xtreg demosup c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store demosup2
xtreg demosup c.lnfdi_jobs##c.educlvl $C1 $C2 $C3 i.round, i(cname)
est store demosup3
xtreg demosup c.lnfdi_capex##c.educlvl $C1 $C2 i.round, i(cname)
est store demosup4
xtprobit demosup c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
est store demosup5
xtreg demosup c.lnfdi_jobs_10##c.educlvl $C1 $C2 i.round, i(cname)
est store demosup6

*** TABLE A-8: Type of Political Regime - Main Models
esttab demoqua2 demoqua4 demoqua5 demosat2 demosat4 demosat5 demosup2 demosup4 demosup5, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(educlvl lnfdi_jobs c.lnfdi_jobs#c.educlvl lnfdi_capex c.lnfdi_capex#c.educlvl age female unempl urban interest news) ///
	drop(*round _cons) eqlabels("" "") nogaps ///
	coeflabel(educlvl "Education level" ///
		lnfdi_jobs "FDI jobs created" ///
		lnfdi_capex "FDI capital expenditure" ///
		c.lnfdi_jobs#c.educlvl "FDI jobs * education" ///
		c.lnfdi_capex#c.educlvl "FDI capex * education" ///
		age "Age in years" female "Female" unempl "Unemployed" ///
		urban "Urban resident" interest "Political interest" ///
		news "Newspaper consumption")

*** TABLE A-9: Type of Political Regime - Robustness Tests
esttab demoqua1 demoqua3 demoqua6 demosat1 demosat3 demosat6 demosup1 demosup3 demosup6, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p ll, fmt(0 0 3 2) labels("\# respondents" "\# of countries" "Prob > Chi2" "Log likelihood")) ///
	order(educlvl lnfdi_jobs c.lnfdi_jobs#c.educlvl age female unempl urban interest news *race) ///
	drop(*round _cons) eqlabels("" "") nogaps ///
	coeflabel(educlvl "Education level" ///
		lnfdi_jobs "FDI jobs created" ///
		lnfdi_capex "FDI capital expenditure" ///
		c.lnfdi_jobs#c.educlvl "FDI jobs * education" ///
		c.lnfdi_capex#c.educlvl "FDI capex * education" ///
		age "Age in years" female "Female" unempl "Unemployed" ///
		urban "Urban resident" interest "Political interest" ///
		news "Newspaper consumption" 1.race "Black/African" ///
		2.race "White/European" 3.race "Colored/mixed race" ///
		4.race "Arab/Lebanese/North African" 5.race "Other")

*** TABLE 1: FDI and Political Preferences, Afrobarometer
esttab problem2 condlive2 condecon2 trustelec2 trustlead2 trustpart2 demoqua2 demosat2 demosup2, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(educlvl lnfdi_jobs c.lnfdi_jobs#c.educlvl age female unempl urban interest news) ///
	drop(*round _cons) eqlabels("" "") nogaps ///
	coeflabel(educlvl "Education level" ///
		lnfdi_jobs "FDI jobs created" ///
		c.lnfdi_jobs#c.educlvl "FDI jobs * education" ///
		age "Age in years" female "Female" unempl "Unemployed" ///
		urban "Urban resident" interest "Political interest" ///
		news "Newspaper consumption")

*** FIGURE 1: Self-Reported Economic Problems
xtreg problem c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, dydx(lnfdi_jobs) at(educlvl=(0(1)9)) vsquish 
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Self-Reported Economic Problems", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(0 9)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(afb_problem, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl if sample==1, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(0 `" "no formal" "education" "' 3 `" "primary" "completed" "' ///
			6 `" "secondary" "completed" "' 9 `" "teritary" "completed" "', labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))
xtreg condlive c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, dydx(lnfdi_jobs) at(educlvl=(0(1)9)) vsquish 
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Bad Living Conditions", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(0 9)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(afb_condlive, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl if sample==1, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(0 `" "no formal" "education" "' 3 `" "primary" "completed" "' ///
			6 `" "secondary" "completed" "' 9 `" "teritary" "completed" "', labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))
xtreg condecon c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, dydx(lnfdi_jobs) at(educlvl=(0(1)9)) vsquish 
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Bad Economic Situation", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(0 9)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(afb_condecon, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl if sample==1, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(0 `" "no formal" "education" "' 3 `" "primary" "completed" "' ///
			6 `" "secondary" "completed" "' 9 `" "teritary" "completed" "', labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))

*** FIGURE 2: Distrust in Electoral Commission
xtreg trustelec c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, dydx(lnfdi_jobs) at(educlvl=(0(1)9)) vsquish 
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Distrust in  Electoral Commission", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(0 9)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(afb_trustelec, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl if sample==1, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(0 `" "no formal" "education" "' 3 `" "primary" "completed" "' ///
			6 `" "secondary" "completed" "' 9 `" "teritary" "completed" "', labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))
xtreg trustlead c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, dydx(lnfdi_jobs) at(educlvl=(0(1)9)) vsquish 
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Distrust in Country's Leader", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(0 9)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(afb_trustlead, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl if sample==1, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(0 `" "no formal" "education" "' 3 `" "primary" "completed" "' ///
			6 `" "secondary" "completed" "' 9 `" "teritary" "completed" "', labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))
xtreg trustpart c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, dydx(lnfdi_jobs) at(educlvl=(0(1)9)) vsquish 
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Distrust in Ruling Coalition", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(0 9)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(afb_trustpart, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl if sample==1, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(0 `" "no formal" "education" "' 3 `" "primary" "completed" "' ///
			6 `" "secondary" "completed" "' 9 `" "teritary" "completed" "', labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))

*** FIGURE 3: Opinion: Country Is Not a Democracy
xtreg demoqua c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, dydx(lnfdi_jobs) at(educlvl=(0(1)9)) vsquish
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Opinion: Country Is Not a Democracy", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(0 9)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(afb_demoqua, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl if sample==1, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(0 `" "no formal" "education" "' 3 `" "primary" "completed" "' ///
			6 `" "secondary" "completed" "' 9 `" "teritary" "completed" "', labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))
xtreg demosat c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, dydx(lnfdi_jobs) at(educlvl=(0(1)9)) vsquish
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Dissatisfaction with Quality of Democracy", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(0 9)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(afb_demosat, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl if sample==1, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(0 `" "no formal" "education" "' 3 `" "primary" "completed" "' ///
			6 `" "secondary" "completed" "' 9 `" "teritary" "completed" "', labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))
xtreg demosup c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, dydx(lnfdi_jobs) at(educlvl=(0(1)9)) vsquish
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Support for Democracy", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(0 9)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(afb_demosup, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl if sample==1, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(0 `" "no formal" "education" "' 3 `" "primary" "completed" "' ///
			6 `" "secondary" "completed" "' 9 `" "teritary" "completed" "', labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))

*** FIGURE A-3: Marginal Effects Plots - All Models
graph combine afb_problem afb_condlive afb_condecon afb_trustelec afb_trustlead ///
	afb_trustpart afb_demoqua afb_demosat afb_demosup, cols(3) iscale(.4) ///
	xsize(5) ysize(6) name(afb_alleffects, replace)

*** TABLE 2: Substantial Effect Sizes (and TABLE A-11: All Models)
* Self-Reported Economic Problems
xtprobit problem c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, post ///
	at(educlvl=1.99 lnfdi_jobs=2.44) ///
	at(educlvl=1.99 lnfdi_jobs=8.42) ///
	at(educlvl=6.31 lnfdi_jobs=2.44) ///
	at(educlvl=6.31 lnfdi_jobs=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
xtoprobit condlive c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, post predict(outcome(5)) ///
	at(educlvl=1.99 lnfdi_jobs=2.44) ///
	at(educlvl=1.99 lnfdi_jobs=8.42) ///
	at(educlvl=6.31 lnfdi_jobs=2.44) ///
	at(educlvl=6.31 lnfdi_jobs=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
xtoprobit condecon c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, post predict(outcome(5)) ///
	at(educlvl=1.99 lnfdi_jobs=2.44) ///
	at(educlvl=1.99 lnfdi_jobs=8.42) ///
	at(educlvl=6.31 lnfdi_jobs=2.44) ///
	at(educlvl=6.31 lnfdi_jobs=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
* Distrust in Electoral Commission
xtprobit trustelec c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, post ///
	at(educlvl=1.99 lnfdi_jobs=2.44) ///
	at(educlvl=1.99 lnfdi_jobs=8.42) ///
	at(educlvl=6.31 lnfdi_jobs=2.44) ///
	at(educlvl=6.31 lnfdi_jobs=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
xtprobit trustlead c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, post ///
	at(educlvl=1.99 lnfdi_jobs=2.44) ///
	at(educlvl=1.99 lnfdi_jobs=8.42) ///
	at(educlvl=6.31 lnfdi_jobs=2.44) ///
	at(educlvl=6.31 lnfdi_jobs=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
xtprobit trustpart c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, post ///
	at(educlvl=1.99 lnfdi_jobs=2.44) ///
	at(educlvl=1.99 lnfdi_jobs=8.42) ///
	at(educlvl=6.31 lnfdi_jobs=2.44) ///
	at(educlvl=6.31 lnfdi_jobs=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
* Opinion: Country Is Not a Democracy
xtoprobit demoqua c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, post predict(outcome(4)) ///
	at(educlvl=1.99 lnfdi_jobs=2.44) ///
	at(educlvl=1.99 lnfdi_jobs=8.42) ///
	at(educlvl=6.31 lnfdi_jobs=2.44) ///
	at(educlvl=6.31 lnfdi_jobs=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
xtoprobit demosat c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, post predict(outcome(3)) ///
	at(educlvl=1.99 lnfdi_jobs=2.44) ///
	at(educlvl=1.99 lnfdi_jobs=8.42) ///
	at(educlvl=6.31 lnfdi_jobs=2.44) ///
	at(educlvl=6.31 lnfdi_jobs=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
xtprobit demosup c.lnfdi_jobs##c.educlvl $C1 $C2 i.round, i(cname)
margins, post ///
	at(educlvl=1.99 lnfdi_jobs=2.44) ///
	at(educlvl=1.99 lnfdi_jobs=8.42) ///
	at(educlvl=6.31 lnfdi_jobs=2.44) ///
	at(educlvl=6.31 lnfdi_jobs=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at

*** Testing the causal mechanism
* Mechanism: Economic grievances --> Low legitimacy
xtreg trustelec problem condlive condecon c.lnfdi_jobs c.educlvl $C1 $C2 i.round, i(cname)
xtreg trustelec problem lnfdi_jobs educlvl $C1 $C2 i.round, i(cname)
est store mech1
xtreg trustelec condlive lnfdi_jobs educlvl $C1 $C2 i.round, i(cname)
est store mech2
xtreg trustelec condecon lnfdi_jobs educlvl $C1 $C2 i.round, i(cname)
est store mech3
* Mechanism: Economic grievances --> Low regime support
xtreg demoqua problem condlive condecon c.lnfdi_jobs c.educlvl $C1 $C2 i.round, i(cname)
xtreg demoqua problem lnfdi_jobs educlvl $C1 $C2 i.round, i(cname)
est store mech4
xtreg demoqua condlive lnfdi_jobs educlvl $C1 $C2 i.round, i(cname)
est store mech5
xtreg demoqua condecon lnfdi_jobs educlvl $C1 $C2 i.round, i(cname)
est store mech6
* Mechanism: Low legitimacy --> Low regime support
xtreg demoqua trustelec trustlead trustpart c.lnfdi_jobs c.educlvl $C1 $C2 i.round, i(cname)
xtreg demoqua trustelec lnfdi_jobs educlvl $C1 $C2 i.round, i(cname)
est store mech7
xtreg demoqua trustlead lnfdi_jobs educlvl $C1 $C2 i.round, i(cname)
est store mech8
xtreg demoqua trustpart lnfdi_jobs educlvl $C1 $C2 i.round, i(cname)
est store mech9

*** TABLE A-10: Testing the Causal Mechanism
esttab mech1 mech2 mech3 mech4 mech5 mech6 mech7 mech8 mech9, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(problem condlive condecon trustelec trustlead trustpart educlvl lnfdi_jobs age female unempl urban interest news) ///
	drop(*round _cons) eqlabels("" "") nogaps ///
	coeflabel(educlvl "Education level" ///
		lnfdi_jobs "FDI jobs created" ///
		age "Age in years" female "Female" unempl "Unemployed" ///
		urban "Urban resident" interest "Political interest" ///
		news "Newspaper consumption")

*** Sensitivity to country selection
* Leave out one country test: Self-Reported Economic Problems
foreach i in 1 4 6 8 9 11 12 16 18 20 21 22 24 29 30 31 32 33 34 36 {
	xtreg problem c.lnfdi_jobs##c.educlvl $C1 $C2 i.round if cname!=`i', i(cname)
	est store problem_`i'
}
coefplot problem_1 problem_4 problem_6 problem_8 problem_9 ///
	problem_11 problem_12 problem_16 problem_18 problem_20 ///
	problem_21 problem_22 problem_24 problem_29 problem_30 ///
	problem_31 problem_32 problem_33 problem_34 problem_36, ///
	keep(lnfdi_jobs c.lnfdi_jobs#c.educlvl) xline(0) ///
	title("Self-Reported Economic Problems") ///
	rename(lnfdi_jobs = "FDI exposure" c.lnfdi_jobs#c.educlvl = "FDI * education") ///
	legend(order(- "Country excluded:" " " 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40) ///
		label(2 "Algeria") label(4 "Burkina Faso") label(6 "Cameroon") label(8 "Egypt") label(10 "Gabon") ///
		label(12 "Guinea") label(14 "Ivory Coast") label(16 "Madagascar") label(18 "Mali") label(20 "Morocco") ///
		label(22 "Mozambique") label(24 "Namibia") label(26 "Nigeria") label(28 "Sudan") label(30 "Swaziland") ///
		label(32 "Tanzania") label(34 "Togo") label(36 "Tunisia") label(38 "Uganda") label(40 "Zimbabwe")) ///
	name(afb_jackknife1, replace)
* Leave out one country test: Distrust in Electoral Commission
foreach i in 1 4 6 8 9 11 12 16 18 20 21 22 24 29 30 31 32 33 34 36 {
	xtreg trustelec c.lnfdi_jobs##c.educlvl $C1 $C2 i.round if cname!=`i', i(cname)
	est store trustelec_`i'
}
coefplot trustelec_1 trustelec_4 trustelec_6 trustelec_8 trustelec_9 ///
	trustelec_11 trustelec_12 trustelec_16 trustelec_18 trustelec_20 ///
	trustelec_21 trustelec_22 trustelec_24 trustelec_29 trustelec_30 ///
	trustelec_31 trustelec_32 trustelec_33 trustelec_34 trustelec_36, ///
	keep(lnfdi_jobs c.lnfdi_jobs#c.educlvl) xline(0) ///
	title("Distrust in Electoral Commission") ///
	rename(lnfdi_jobs = "FDI exposure" c.lnfdi_jobs#c.educlvl = "FDI * education") ///
	legend(order(- "Country excluded:" " " 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40) ///
		label(2 "Algeria") label(4 "Burkina Faso") label(6 "Cameroon") label(8 "Egypt") label(10 "Gabon") ///
		label(12 "Guinea") label(14 "Ivory Coast") label(16 "Madagascar") label(18 "Mali") label(20 "Morocco") ///
		label(22 "Mozambique") label(24 "Namibia") label(26 "Nigeria") label(28 "Sudan") label(30 "Swaziland") ///
		label(32 "Tanzania") label(34 "Togo") label(36 "Tunisia") label(38 "Uganda") label(40 "Zimbabwe")) ///
	name(afb_jackknife2, replace)
* Leave out one country test: Opinion: Country Is Not a Democracy
foreach i in 1 4 6 8 9 11 12 16 18 20 21 22 24 29 30 31 32 33 34 36 {
	xtreg demoqua c.lnfdi_jobs##c.educlvl $C1 $C2 i.round if cname!=`i', i(cname)
	est store demoqua_`i'
}
coefplot demoqua_1 demoqua_4 demoqua_6 demoqua_8 demoqua_9 ///
	demoqua_11 demoqua_12 demoqua_16 demoqua_18 demoqua_20 ///
	demoqua_21 demoqua_22 demoqua_24 demoqua_29 demoqua_30 ///
	demoqua_31 demoqua_32 demoqua_33 demoqua_34 demoqua_36, ///
	keep(lnfdi_jobs c.lnfdi_jobs#c.educlvl) xline(0) ///
	title("Opinion: Country Is Not a Democracy") ///
	rename(lnfdi_jobs = "FDI exposure" c.lnfdi_jobs#c.educlvl = "FDI * education") ///
	legend(order(- "Country excluded:" " " 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40) ///
		label(2 "Algeria") label(4 "Burkina Faso") label(6 "Cameroon") label(8 "Egypt") label(10 "Gabon") ///
		label(12 "Guinea") label(14 "Ivory Coast") label(16 "Madagascar") label(18 "Mali") label(20 "Morocco") ///
		label(22 "Mozambique") label(24 "Namibia") label(26 "Nigeria") label(28 "Sudan") label(30 "Swaziland") ///
		label(32 "Tanzania") label(34 "Togo") label(36 "Tunisia") label(38 "Uganda") label(40 "Zimbabwe")) ///
	name(afb_jackknife3, replace)

*** FIGURE A-4: Combined jackkknife graph
graph combine afb_jackknife1 afb_jackknife2 afb_jackknife3, col(1) iscale(.5) ///
	xsize(5) ysize(6) name(afb_jackknife, replace)



***** 2. Pew Global Attitudes Survey Data
*------------------------------------------------------------------------------*

*** Load data
use "Rommel_FDIsupport_CPS_PEW.dta", clear

*** Model specification
* Controls
global C1 age gender unemp urban
global C2 income intnews 
global C3 religion remit married children relatives 
* Sample
xtreg problem c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
gen sample=e(sample)==1

*** TABLE A-12: Summary statistics, Pew Global Attitudes
tabstat problem worse leadsat legit_free legit_judi legit_mili ///
	educlvl lnfdi_capex lnfdi_jobs age gender unemp urban income intnews ///
	religion remit married children relatives if sample==1, ///
	stats(N mean sd min max) format(%10.2f)

*** Set 1: Economic and Political Attitudes
* Self-Reported Economic Problems
xtreg problem c.lnfdi_capex##c.educlvl $C1, i(ccode)
est store problem1
xtreg problem c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store problem2
xtreg problem c.lnfdi_capex##c.educlvl $C1 $C2 $C3, i(ccode)
est store problem3
xtoprobit problem c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store problem4
xtreg problem c.lnfdi_capex##c.educdev $C1 $C2, i(ccode)
est store problem5
xtreg problem c.lnfdi_jobs##c.educlvl $C1 $C2, i(ccode)
est store problem6
* Expected Social Decline
xtreg worse c.lnfdi_capex##c.educlvl $C1, i(ccode)
est store worse1
xtreg worse c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store worse2
xtreg worse c.lnfdi_capex##c.educlvl $C1 $C2 $C3, i(ccode)
est store worse3
xtoprobit worse c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store worse4
xtreg worse c.lnfdi_capex##c.educdev $C1 $C2, i(ccode)
est store worse5
xtreg worse c.lnfdi_jobs##c.educlvl $C1 $C2, i(ccode)
est store worse6
* Leader Satisfaction
xtreg leadsat c.lnfdi_capex##c.educlvl $C1, i(ccode)
est store leadsat1
xtreg leadsat c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store leadsat2
xtreg leadsat c.lnfdi_capex##c.educlvl $C1 $C2 $C3, i(ccode)
est store leadsat3
xtoprobit leadsat c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store leadsat4
xtreg leadsat c.lnfdi_capex##c.educdev $C1 $C2, i(ccode)
est store leadsat5
xtreg leadsat c.lnfdi_jobs##c.educlvl $C1 $C2, i(ccode)
est store leadsat6

*** TABLE A-14: Economic and Political Attitudes - Main Models
esttab problem2 problem3 problem4 worse2 worse3 worse4 leadsat2 leadsat3 leadsat4, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(educlvl lnfdi_capex c.lnfdi_capex#c.educlvl age gender unemp urban income intnews ///
		religion remit married children relatives) ///
	drop(_cons) eqlabels("" "") nogaps
	
*** TABLE A-15: Economic and Political Attitudes - Robustness Tests
esttab problem1 problem5 problem6 worse1 worse5 worse6 leadsat1 leadsat5 leadsat6, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(educlvl educdev lnfdi_capex c.lnfdi_capex#c.educlvl lnfdi_jobs c.lnfdi_jobs#c.educlvl c.lnfdi_capex#c.educdev ///
		age gender unemp urban income intnews) ///
	drop(_cons) eqlabels("" "") nogaps

*** Set 2: Perceived Regime Legitimacy
* Legitimacy Belief: Freedom of Speech
xtreg legit_free c.lnfdi_capex##c.educlvl $C1, i(ccode)
est store legit_free1
xtreg legit_free c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store legit_free2
xtreg legit_free c.lnfdi_capex##c.educlvl $C1 $C2 $C3, i(ccode)
est store legit_free3
xtoprobit legit_free c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store legit_free4
xtreg legit_free c.lnfdi_capex##c.educdev $C1 $C2, i(ccode)
est store legit_free5
xtreg legit_free c.lnfdi_jobs##c.educlvl $C1 $C2, i(ccode)
est store legit_free6
* Legitimacy Belief: Judiciary
xtreg legit_judi c.lnfdi_capex##c.educlvl $C1, i(ccode)
est store legit_judi1
xtreg legit_judi c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store legit_judi2
xtreg legit_judi c.lnfdi_capex##c.educlvl $C1 $C2 $C3, i(ccode)
est store legit_judi3
xtoprobit legit_judi c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store legit_judi4
xtreg legit_judi c.lnfdi_capex##c.educdev $C1 $C2, i(ccode)
est store legit_judi5
xtreg legit_judi c.lnfdi_jobs##c.educlvl $C1 $C2, i(ccode)
est store legit_judi6
* Legitimacy Belief: Military Control
xtreg legit_mili c.lnfdi_capex##c.educlvl $C1, i(ccode)
est store legit_mili1
xtreg legit_mili c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store legit_mili2
xtreg legit_mili c.lnfdi_capex##c.educlvl $C1 $C2 $C3, i(ccode)
est store legit_mili3
xtoprobit legit_mili c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
est store legit_mili4
xtreg legit_mili c.lnfdi_capex##c.educdev $C1 $C2, i(ccode)
est store legit_mili5
xtreg legit_mili c.lnfdi_jobs##c.educlvl $C1 $C2, i(ccode)
est store legit_mili6

*** TABLE A-16: Perceived Regime Legitimacy - Main Models
esttab legit_free2 legit_free3 legit_free4 legit_judi2 legit_judi3 legit_judi4 legit_mili2 legit_mili3 legit_mili4, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(educlvl lnfdi_capex c.lnfdi_capex#c.educlvl age gender unemp urban income intnews ///
		religion remit married children relatives) ///
	drop(_cons) eqlabels("" "") nogaps
	
*** TABLE A-17: Perceived Regime Legitimacy - Robustness Tests
esttab legit_free1 legit_free5 legit_free6 legit_judi1 legit_judi5 legit_judi6 legit_mili1 legit_mili5 legit_mili6, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(educlvl educdev lnfdi_capex c.lnfdi_capex#c.educlvl lnfdi_jobs c.lnfdi_jobs#c.educlvl c.lnfdi_capex#c.educdev ///
		age gender unemp urban income intnews) ///
	drop(_cons) eqlabels("" "") nogaps

*** TABLE 3: FDI and Political Preferences, Pew Global Attitudes
esttab problem2 worse2 leadsat2 legit_free2 legit_judi2 legit_mili2, ///
	b(3) se(2) starlevels(* 0.10 ** 0.05 *** 0.01) ///
	stats(N N_g p, fmt(0 0 3) labels("\# respondents" "\# of countries" "Prob > Chi2")) ///
	order(educlvl lnfdi_capex c.lnfdi_capex#c.educlvl age gender unemp urban income intnews) ///
	drop(_cons) eqlabels("" "") nogaps

*** Self-Reported Economic Problems
xtreg problem c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
margins, dydx(lnfdi_capex) at(educlvl=(0(1)5)) vsquish
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Self-Reported Economic Problems", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(-0.5 5.5)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(pew_problem, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(, labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))

*** Legitimacy Belief: Freedom of Speech
xtreg legit_free c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
margins, dydx(lnfdi_capex) at(educlvl=(0(1)5)) vsquish
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Legitimacy Belief: Freedom of Speech", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(-0.5 5.5)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(pew_legit_free, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(, labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))

*** Legitimacy Belief: Judiciary
xtreg legit_judi c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
margins, dydx(lnfdi_capex) at(educlvl=(0(1)5)) vsquish
marginsplot, level(95) ///
	plotopts(msymbol(i) lcolor(black)) ///
	ciopts(recast(rline) lpattern(dash) lcolor(black)) ///
	title("Legitimacy Belief: Judiciary", size(medium) margin(medsmall)) ///
	xtitle("Individual education level", size(medsmall) margin(medsmall)) ///
	ytitle("Marginal effect of FDI exposure", size(medsmall) margin(off)) ///
	ylabel(, nogrid)  ///
	xscale(range(-0.5 5.5)) ///
	xlabel(, labsize(small) nogrid) ///
	yline(0, lcolor(black) lwidth(.2)) ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
	name(pew_legit_judi, replace) xsize(2) ysize(2) ///
	addplot(hist educlvl, disc yaxis(2) legend(off) ///
		ytitle("", axis(2)) ylabel(none, axis(2)) ///
		xlabel(, labsize(small) nogrid) ///
		fcolor(none) lcolor(gs12))

*** FIGURE A-5: Combined marginal effects plots
graph combine pew_problem pew_legit_free pew_legit_judi, col(1) iscale(.8) ///
	xsize(2) ysize(5) name(pew_alleffects, replace)

*** TABLE A-18: Substantial Effect Sizes - All Models
* Self-Reported Economic Problems
xtprobit problem c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
margins, post ///
	at(educlvl=1.40 lnfdi_capex=2.08) ///
	at(educlvl=1.40 lnfdi_capex=8.42) ///
	at(educlvl=4.50 lnfdi_capex=2.08) ///
	at(educlvl=4.50 lnfdi_capex=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
* Expected Social Decline
xtreg worse c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
margins, post ///
	at(educlvl=1.40 lnfdi_capex=2.08) ///
	at(educlvl=1.40 lnfdi_capex=8.42) ///
	at(educlvl=4.50 lnfdi_capex=2.08) ///
	at(educlvl=4.50 lnfdi_capex=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
* Leader Satisfaction
xtoprobit leadsat c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
margins, post predict(outcome(4)) ///
	at(educlvl=1.40 lnfdi_capex=2.08) ///
	at(educlvl=1.40 lnfdi_capex=8.42) ///
	at(educlvl=4.50 lnfdi_capex=2.08) ///
	at(educlvl=4.50 lnfdi_capex=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
* Legitimacy Belief: Freedom of Speech
xtoprobit legit_free c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
margins, post predict(outcome(3)) ///
	at(educlvl=1.40 lnfdi_capex=2.08) ///
	at(educlvl=1.40 lnfdi_capex=8.42) ///
	at(educlvl=4.50 lnfdi_capex=2.08) ///
	at(educlvl=4.50 lnfdi_capex=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
* Legitimacy Belief: Judiciary
xtoprobit legit_judi c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
margins, post predict(outcome(3)) ///
	at(educlvl=1.40 lnfdi_capex=2.08) ///
	at(educlvl=1.40 lnfdi_capex=8.42) ///
	at(educlvl=4.50 lnfdi_capex=2.08) ///
	at(educlvl=4.50 lnfdi_capex=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at
* Legitimacy Belief: Military Control
xtoprobit legit_mili c.lnfdi_capex##c.educlvl $C1 $C2, i(ccode)
margins, post predict(outcome(3)) ///
	at(educlvl=1.40 lnfdi_capex=2.08) ///
	at(educlvl=1.40 lnfdi_capex=8.42) ///
	at(educlvl=4.50 lnfdi_capex=2.08) ///
	at(educlvl=4.50 lnfdi_capex=8.42) atmeans
margins, coeflegend
lincom 2._at - 1._at
test 2._at = 1._at
lincom 4._at - 3._at
test 4._at = 3._at



*------------------------------------------------------------------------------*


capture log close
exit
